home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxcrc32.zip / CRC of File.CMD next >
OS/2 REXX Batch file  |  1998-01-24  |  2KB  |  47 lines

  1. /* RxCRC32-Test: Calculate CRC-32 of Stored File *
  2.  *                                               *
  3.  * (C) Mads Orbesen Troest & SIRIUS Cybernetics  */
  4.  
  5. ARG FileName /* Get FileName on CommandLine */
  6. IF FileName = "" THEN EXIT /* Exit if no FileName Specified */
  7.  
  8. /* Define a BufferSize for the blocks read from the File */
  9. /* Do not set too low as this gives unnecessary calling-overhead! */
  10. /* Set it after how much memory you are willing to spend on it... :-) */
  11.  
  12. BufferSize = 4096 /* Can't be that bad a size; could be bigger though .-) */
  13.  
  14. /* Load External RxCRC32 Routines: */
  15.  
  16. CALL RxFuncAdd "RxCRC32Ver",    "RXCRC32", "RXCRC32VER"
  17. CALL RxFuncAdd "RxCRC32Init",   "RXCRC32", "RXCRC32INIT"
  18. CALL RxFuncAdd "RxCRC32Done",   "RXCRC32", "RXCRC32DONE"
  19. CALL RxFuncAdd "RxCRC32Update", "RXCRC32", "RXCRC32UPDATE"
  20.  
  21. /* Do some initial chitchat: */
  22.  
  23. SAY ""
  24. SAY "RxCRC32-Test: Calculate CRC-32 of Stored File, utilising:"
  25. SAY RxCRC32Ver() /* Report Version Information */
  26. SAY ""
  27.  
  28. /* Initialize the variable CRC for as in CRC-calculation: */
  29.  
  30. CRC = RxCRC32Init()
  31.  
  32. /* Calculate CRC-32 of File: */
  33.  
  34. DO UNTIL LENGTH( Buffer ) \= BufferSize /* Traverse File */
  35.  Buffer = CHARIN( FileName,, BufferSize ) /* Fill Buffer (there may be a faster way :-) */
  36.  CRC = RxCRC32Update( CRC, Buffer ) /* Update CRC with Buffer */
  37. END
  38.  
  39. /* Complete Calculation: */
  40.  
  41. CRC = RxCRC32Done( CRC )
  42.  
  43. /* Report the result: */
  44.  
  45. SAY "Well, then... CRC-32 : "CRC" (HEX) - Thanks for using RxCRC32 :-)"
  46.  
  47.